function calcMom(srcArr, tar, index){
	if (typeof srcArr == "undefined" || srcArr == 0 
		|| typeof tar == "undefined" 
		|| tar == 0 || index==0 || typeof index == "undefined"){
		return 0;
	}
	var i = parseInt(index);
	
	return (tar-srcArr[i-1])/srcArr[i-1]*100;
}

function calcWeek(sdate,edate,weeks,airport,skyway,ch_airport){
	if (typeof sdate == "undefined" || sdate == 0 
		|| typeof edate == "undefined" || typeof airport == "undefined"
		|| edate == 0 || weeks==0 || typeof weeks == "undefined"
        || typeof skyway == "undefined" || typeof ch_airport == "undefined"){
		return 0;
	}
	var sd = new Date(sdate);  
	var ed = new Date(edate);

    // 切割航线取值
    var arr_skyway = skyway.split("-");
    var first_param = arr_skyway[0];
    var end_param = arr_skyway[arr_skyway.length-1];
    if (airport == first_param || airport == end_param) {
        return getAll(sd,ed,""+weeks)*2;
    }else {
        if(ch_airport.indexOf(first_param)!=-1||ch_airport.indexOf(end_param)!=-1){
            return getAll(sd,ed,""+weeks)*2;
        }else {
            return getAll(sd,ed,""+weeks)*4;
        }
    }

}

//获取日期范围内所有的星期
function getAll(startTime, endTime, weeks) {
  var weekList = 0;
  while (endTime.getTime() - startTime.getTime() >= 0) {
    var year = startTime.getFullYear();
    var month =
      startTime.getMonth().toString().length === 1
        ? '0' + startTime.getMonth().toString()
        : startTime.getMonth();
    var day =
      startTime.getDate().toString().length === 1
        ? '0' + startTime.getDate()
        : startTime.getDate();
    
    var tempm = parseInt(month) + 1;
    var m = tempm.toString().length === 1? '0' + tempm: tempm;
    
    var date = year + '-' + m + '-' + day;
    if (weeks.indexOf(getWeekDate(date)) != -1) {
    	weekList += 1;
    }
    startTime.setDate(startTime.getDate() + 1);
  }

  return weekList;
}

//获取当前日期星期几
function getWeekDate(time) {
  var now = new Date(time);
  var day = now.getDay();
  var weeks = ["7", "1", "2", "3", "4", "5", "6"];
  var week = weeks[day];
  return week;
}
